﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace YJKCopyModel.YJKRevitWndr
{
	[Grouper(GrouperName = "DoorAndWindowGrouper")]
	public class DoorAndWindowGrouper : IDataGrouper
	{
		public List<RevitModelRequest> GroupData(InputRequest inputRequest)
		{
			List<RevitModelRequest> list = new List<RevitModelRequest>();
			try
			{
				DoorAndWindowRequest doorAndWindowRequest = inputRequest as DoorAndWindowRequest;
				foreach (ICadElement cadElement in doorAndWindowRequest.SelectDataMap.First<KeyValuePair<string, List<ICadElement>>>().Value)
				{
					DoorAndWindowRevitModelRequest doorAndWindowRevitModelRequest = new DoorAndWindowRevitModelRequest();
					DoorAndWindowCadElement requestData = new DoorAndWindowCadElement(cadElement as DoorAndWindowBlockRefInfo);
					doorAndWindowRevitModelRequest.RequestData = requestData;
					doorAndWindowRevitModelRequest.ThisConfigInfo = doorAndWindowRequest.ThisConfigInfo;
					doorAndWindowRevitModelRequest.IfNeedRegenerate = true;
					list.Add(doorAndWindowRevitModelRequest);
				}
			}
			catch (Exception ex)
			{
				Trace.Assert(true, ex.Message);
			}
			return list;
		}
	}
}
